﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using cart.dao;
using cart.model;

namespace cart.service
{
    public class orderItemsService
    {
        public ArrayList getOrderItemsByOrderID(int orderID)
        {
            orderItemsDao oid = new orderItemsDao();
            return oid.getOrderItemsByOrderID(orderID);
        }

        //得到单个商品的总价格
        public double getSubTotle(orderItemsModel oim)
        {
            double subTotle = 0;
            subTotle = oim.memberPrice * oim.productNumber;
            return subTotle;
        }

        public Boolean addOrderItems(ArrayList alOrderItems)
        {
            try
            {
                foreach (orderItemsModel oim in alOrderItems)
                {
                    addOrderItem(oim);
                }
                return true;
            }
            catch
            {
                return false;
            }
        }

        public Boolean addOrderItem(orderItemsModel oim)
        {
            orderItemsDao oid = new orderItemsDao();
            return oid.addOrderItem(oim);
        }
    }
}
